package m202406.d11;

import java.util.*;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/6/11 16:41
 */
public class Q49 {
    public List<List<String>> groupAnagrams(String[] strs) {
        Map<String, List<String>> map = new HashMap<>();
        for (String str : strs) {
            char[] array = str.toCharArray();
            Arrays.sort(array);
            String key = new String(array);
            List<String> dv = map.getOrDefault(key, new ArrayList<>());
            dv.add(str);
            map.put(key, dv);
        }
        return new ArrayList<>(map.values());
    }
}
